Skip to content

Use dynamic filtering for extra attributes#107

Merged
nikhilNava merged 3 commits into
mainfrom
nikhilc/extra-attributes-dynamic-filtering
Jul 6, 2026
Merged

Use dynamic filtering for extra attributes#107
nikhilNava merged 3 commits into
mainfrom
nikhilc/extra-attributes-dynamic-filtering

Conversation

@nikhilNava

Copy link
Copy Markdown
Collaborator

Extra attributes can now add any key that the builder did not already set on the span, rather than being blocked by a hardcoded 40-key allowlist. This allows attributes like gen_ai.request.model to be set on invoke_agent spans via extraAttributes while still preventing overrides of builder-set keys.

Ported from microsoft/Agent365-dotnet#254

Extra attributes can now add any key that the builder did not already set on
the span, rather than being blocked by a hardcoded 40-key allowlist. This
allows attributes like gen_ai.request.model to be set on invoke_agent spans
via extraAttributes while still preventing overrides of builder-set keys.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Agent365 telemetry data builders to accept a wider set of extraAttributes by filtering dynamically: extra attributes are added only when they don’t conflict with keys already set by the builder, rather than using a fixed reserved-key allowlist. This enables scenarios like setting gen_ai.request.model on invoke_agent spans via extraAttributes when the builder doesn’t set it.

Changes:

  • Removed the hardcoded reserved-key allowlist and switched to “don’t override existing keys” filtering for extra attributes.
  • Added a regression test ensuring gen_ai.request.model can be supplied via extraAttributes for InvokeAgentDataBuilder when not builder-set.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/Microsoft.OpenTelemetry.Agent365.Tests/Runtime/DTOs/Builders/InvokeAgentDataBuilderTests.cs Adds test coverage for allowing gen_ai.request.model via extraAttributes when not set by the builder.
src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/BaseDataBuilder.cs Replaces allowlist-based filtering with dynamic filtering that blocks overriding already-set builder attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nikhilNava nikhilNava enabled auto-merge (squash) May 26, 2026 19:32
nikhilc-microsoft and others added 2 commits July 6, 2026 07:36
…tes-dynamic-filtering

# Conflicts:
#	src/Microsoft.OpenTelemetry/Agent365/Runtime/DTOs/Builders/BaseDataBuilder.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nikhilNava nikhilNava merged commit 32a24d6 into main Jul 6, 2026
10 checks passed
@nikhilNava nikhilNava deleted the nikhilc/extra-attributes-dynamic-filtering branch July 6, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants